package com.maiji.cloud.controller.login;

import com.maiji.cloud.controller.BaseController;
import com.maiji.cloud.entities.login.AppUser;
import com.maiji.cloud.entities.shopingmall.CapitalMainLog;
import com.maiji.cloud.request.BaseDataReqDto;
import com.maiji.cloud.request.login.*;
import com.maiji.cloud.response.BaseDataResDto;
import com.maiji.cloud.response.BaseMetaResDto;
import com.maiji.cloud.response.BaseResDto;
import com.maiji.cloud.response.login.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/userInterface/")
@Api(tags = {"用户信息模块"})
public class UserController extends BaseController {

	/**
	 * 获得进入app设置的个人信息
	 * 
	 * @param maijiToken
	 * @return
	 */
	@ApiOperation(value = "获得进入app设置的个人信息 ")
	@PostMapping("/getUserInfo")
	public UserInfoResDto getUserInfo_query(@RequestHeader("maijiToken") String maijiToken) {
		HttpHeaders headers = new HttpHeaders();
		headers.add("maijiToken", maijiToken);
		HttpEntity<String> httpEntity = new HttpEntity<>(headers);
		return restTemplate.postForObject(REST_URL_APPLOGIN + "/user/getUserInfo", httpEntity, UserInfoResDto.class);
	}

    /**
     * 获取尿酮
     * @param maijiToken
     * @return
     */
    @PostMapping("getKetonuria")
    @ApiOperation(value = "获取最新尿酮记录")
    public BaseDataResDto<List<WeightChangeLogResData>> getKetonuria_query(@RequestBody BaseDataReqDto<GetKetonuriaResData> param,
                                                                     @RequestHeader("maijiToken")String maijiToken) {
        return postForObjectWithToken(maijiToken,REST_URL_APPLOGIN + "/user/getKetonuria", param, BaseDataResDto.class);
    }

	/**
	 * 获得一个用户的所有的体重记录
	 * @param maijiToken
	 * @return
	 */
	@ApiOperation(value = "获得一个用户的所有的体重记录 ")
	@PostMapping("/getWeightChangeLogList")
	public WeightChangeLogListResDto getWeightChangeLogList_query(@RequestHeader("maijiToken")String maijiToken){
		
		HttpHeaders headers = new HttpHeaders();
		headers.add("maijiToken", maijiToken);
		HttpEntity<String> httpEntity = new HttpEntity<>(headers);
		return restTemplate.postForObject(REST_URL_APPLOGIN + "/user/getWeightChangeLogList", httpEntity, WeightChangeLogListResDto.class);
	}

	/**
	 * 获取用户列表
	 * @param baseDataReqDto
	 * @return
	 */
	@PostMapping("findAllMaijiUsers")
	@ApiOperation(value = "获取用户列表")
	public BaseMetaResDto<List<UserInfoResData>> findAllMaijiUsers(@RequestBody BaseDataReqDto<MaijiUserFindAllReqData> baseDataReqDto){
		return restTemplate.postForObject(REST_URL_APPLOGIN + "/user/findAllMaijiUsers", baseDataReqDto, BaseMetaResDto.class);
	}

	/**
	 * 获取用户资金流水列表
	 * @param baseDataReqDto
	 * @return
	 */
	@PostMapping("findAllCapitalMainLogs")
	@ApiOperation(value = "获取用户资金流水列表")
	public BaseMetaResDto<List<CapitalMainLog>> findAllCapitalMainLogs(@RequestBody BaseDataReqDto<CapitalMainLog> baseDataReqDto){
		return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/capital/findAllCapitalMainLogs", baseDataReqDto, BaseMetaResDto.class);
	}

    /**
     * 获取用户资金统计数据
     * @return
     */
    @ApiOperation(value = "获取用户资金统计数据 ")
    @PostMapping("findCapitalMainCount")
    public BaseDataResDto<Map<String, Object>> findCapitalMainCount(){
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/capitalMain/findCapitalMainCount", null, BaseDataResDto.class);
    }


    /**
     * 禁止用户登录
     * @return
     */
    @ApiOperation(value = "禁止用户登录 ")
    @PostMapping("banAppUser")
    public BaseResDto banAppUser(@RequestBody BaseDataReqDto<AppUser> baseDataReqDto){
        return restTemplate.postForObject(REST_URL_APPLOGIN + "/banAppUser", baseDataReqDto, BaseResDto.class);
    }

}
